package com.ygxsk.carhome.ui.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.flyco.roundview.RoundTextView;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.enumwrap.InfoMationAuditStatus;
import com.ygxsk.carhome.response.CarInfoVehicleBean;
import com.ygxsk.carhome.utils.CommUtils;

import java.util.List;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-11-07  09:03
 * @Description:多车辆，在客户档案的详情内的列表内容
 */
public class ArchiveFileCarInfoDetailAdapter extends BaseQuickAdapter<CarInfoVehicleBean, BaseViewHolder> {

    //添加单个车辆
//    private MyArchiveFileCarInfoAddListener myArchiveFileCarInfoAddListener;

    private String auditStatus;

    public ArchiveFileCarInfoDetailAdapter(int layoutResId, @Nullable List<CarInfoVehicleBean> data, String _auditStatus) {
        super(layoutResId, data);

//        this.myArchiveFileCarInfoAddListener = _myArchiveFileCarInfoAddListener;
        auditStatus = _auditStatus;

        addChildClickViewIds(R.id.roundtextvieweditcarinforightmore);

    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, CarInfoVehicleBean _carInfoVehicleBean) {

        if (_carInfoVehicleBean != null) {

            //车辆的编号
            String number = _carInfoVehicleBean.getNumber();

            //车牌号
            String licenseNumber = _carInfoVehicleBean.getLicenseNumber();

            //车架号码
            String vin = _carInfoVehicleBean.getVin();

            //发动机号
            String engineNum = _carInfoVehicleBean.getEngineNum();

            //车辆品牌--的数字格式
//            String carBranch = _carInfoVehicleBean.getCarBranch();
            //车辆品牌--的汉字格式
            String carBranchName = _carInfoVehicleBean.getCarBranchName();

            //车辆车系--的汉字格式
            String carSeriesName = _carInfoVehicleBean.getCarSeriesName();

            //车辆型号
            String carModel = _carInfoVehicleBean.getCarModel();

            //-----------------------------------------------------------------------------------------------------------------------------------------------

            //编辑车辆信息的按钮
            RoundTextView roundTextViewEditCarInfoRight = (RoundTextView) baseViewHolder.getView(R.id.roundtextvieweditcarinforightmore);

            //车辆的编号
            TextView textViewInspectDotNameDesNumber = (TextView) baseViewHolder.getView(R.id.textviewinspectdotnamedesnumberada);
            //车牌号
            TextView textViewFileCarCard = (TextView) baseViewHolder.getView(R.id.textviewfilecarcardmore);
            //车架号码
            TextView textViewFileCarFrame = (TextView) baseViewHolder.getView(R.id.textviewfilecarframemore);
            //发动机号
            TextView textViewFileCarMotor = (TextView) baseViewHolder.getView(R.id.textviewfilecarmotormore);
            //品牌型号
            TextView textViewFileCarBrandModel = (TextView) baseViewHolder.getView(R.id.textviewfilecarbrandmodelmore);
            //车辆车系
            TextView textViewFileCarModelLine = (TextView) baseViewHolder.getView(R.id.textviewfilecarmodellinemore);
            //车辆型号
            TextView textViewFileCarModelSmall = (TextView) baseViewHolder.getView(R.id.textviewfilecarmodelsmallmore);

            //底部的最后一条横线，有显示和隐藏的时机
            TextView textViewHelpInDetailMiddleBottom = (TextView) baseViewHolder.getView(R.id.textviewhelpindetailmiddlebottom);

            //------------------------------------------------------------------------------------------------------------------------------------
            if (TextUtils.equals(auditStatus, String.valueOf(InfoMationAuditStatus.AUDITSTATUS_INPUTING.getIndex()))//
                    || TextUtils.equals(auditStatus, String.valueOf(InfoMationAuditStatus.AUDITSTATUS_TO_BE_VERIFY.getIndex()))//
                    || TextUtils.equals(auditStatus, String.valueOf(InfoMationAuditStatus.AUDITSTATUS_NOT_PASS.getIndex()))//
            ) {

                CommUtils.setViewVisible(roundTextViewEditCarInfoRight);

            } else if (TextUtils.equals(auditStatus, String.valueOf(InfoMationAuditStatus.AUDITSTATUS_HAS_PASS.getIndex()))) {
                CommUtils.setViewGone(roundTextViewEditCarInfoRight);
            }
            //------------------------------------------------------------------------------------------------------------------------------------
            //车辆的编号
            textViewInspectDotNameDesNumber.setText(number);

            //车牌
            CommUtils.setText(textViewFileCarCard, licenseNumber);
            //车架子号
            CommUtils.setText(textViewFileCarFrame, vin);
            //发动机号
            CommUtils.setText(textViewFileCarMotor, engineNum);
            //车辆品牌
            CommUtils.setText(textViewFileCarBrandModel, carBranchName);
            //车系-车系列
            CommUtils.setText(textViewFileCarModelLine, carSeriesName);
            //车辆型号
            CommUtils.setText(textViewFileCarModelSmall, carModel);

            //如果是最后一条数据，那么要隐藏底部的隔断线
            int indexPositionLast = getItemPosition(_carInfoVehicleBean);

            if (indexPositionLast == (getData().size() - 1)) {
                //隐藏
                textViewHelpInDetailMiddleBottom.setVisibility(View.GONE);
            } else {
                //展示
                textViewHelpInDetailMiddleBottom.setVisibility(View.VISIBLE);
            }


        }

    }
}
